/*   1:    */ package org.jetbrains.jps.model.module.impl;
/*   2:    */ 
/*   3:    */

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.*;
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
import org.jetbrains.jps.model.ex.JpsNamedCompositeElementBase;
import org.jetbrains.jps.model.impl.JpsUrlListRole;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryCollection;
import org.jetbrains.jps.model.library.JpsLibraryType;
import org.jetbrains.jps.model.library.JpsTypedLibrary;
import org.jetbrains.jps.model.library.impl.JpsLibraryCollectionImpl;
import org.jetbrains.jps.model.library.impl.JpsLibraryRole;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
import org.jetbrains.jps.model.module.*;

import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */
/*  25:    */
/*  26:    */
/*  27:    */
/*  28:    */
/*  29:    */
/*  30:    */
/*  31:    */
/*  32:    */
/*  33:    */
/*  34:    */
/*  35:    */ 
/*  36:    */ public class JpsModuleImpl<P extends JpsElement>
/*  37:    */   extends JpsNamedCompositeElementBase<JpsModuleImpl<P>>
/*  38:    */   implements JpsTypedModule<P>
/*  39:    */ {
/*  40: 41 */   private static final JpsUrlListRole a = new JpsUrlListRole("content roots");
/*  41: 42 */   private static final JpsUrlListRole b = new JpsUrlListRole("excluded roots");
/*  42: 43 */   private static final JpsElementChildRole<JpsDependenciesListImpl> c = JpsElementChildRoleBase.create("dependencies");
/*  43:    */   private final JpsModuleType<P> d;
/*  44:    */   private final JpsLibraryCollection e;
/*  45:    */   
/*  46:    */   public JpsModuleImpl(JpsModuleType<P> paramJpsModuleType, @NotNull String paramString, @NotNull P paramP)
/*  47:    */   {
/*  48: 48 */     super(paramString);
/*  49: 49 */     this.d = paramJpsModuleType;
/*  50: 50 */     this.myContainer.setChild(this.d.getPropertiesRole(), paramP);
/*  51: 51 */     this.myContainer.setChild(a);
/*  52: 52 */     this.myContainer.setChild(b);
/*  53: 53 */     this.myContainer.setChild(c, new JpsDependenciesListImpl());
/*  54: 54 */     getDependenciesList().addModuleSourceDependency();
/*  55: 55 */     this.e = new JpsLibraryCollectionImpl((JpsElementCollection)this.myContainer.setChild(JpsLibraryRole.LIBRARIES_COLLECTION_ROLE));
/*  56: 56 */     this.myContainer.setChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE);
/*  57: 57 */     this.myContainer.setChild(JpsSdkReferencesTableImpl.ROLE);
/*  58:    */   }
/*  59:    */   
/*  60:    */   private JpsModuleImpl(JpsModuleImpl<P> paramJpsModuleImpl)
/*  61:    */   {
/*  62: 61 */     super(paramJpsModuleImpl);
/*  63: 62 */     this.d = paramJpsModuleImpl.d;
/*  64: 63 */     this.e = new JpsLibraryCollectionImpl((JpsElementCollection)this.myContainer.getChild(JpsLibraryRole.LIBRARIES_COLLECTION_ROLE));
/*  65:    */   }
/*  66:    */   
/*  67:    */   @NotNull
/*  68:    */   public JpsModuleImpl<P> createCopy()
/*  69:    */   {
/*  70: 69 */     void tmp8_5 = new JpsModuleImpl(this);
/*  71: 69 */     if (tmp8_5 == null) {
/*  72: 69 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "createCopy" }));
/*  73:    */     }
/*  74: 69 */     return tmp8_5;
/*  75:    */   }
/*  76:    */   
/*  77:    */   public JpsElementType<P> getType()
/*  78:    */   {
/*  79: 74 */     return this.d;
/*  80:    */   }
/*  81:    */   
/*  82:    */   @NotNull
/*  83:    */   public P getProperties()
/*  84:    */   {
/*  85: 80 */     JpsElement tmp16_13 = this.myContainer.getChild(this.d.getPropertiesRole());
/*  86: 80 */     if (tmp16_13 == null) {
/*  87: 80 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getProperties" }));
/*  88:    */     }
/*  89: 80 */     return tmp16_13;
/*  90:    */   }
/*  91:    */   
/*  92:    */   public <P extends JpsElement> JpsTypedModule<P> asTyped(@NotNull JpsModuleType<P> paramJpsModuleType)
/*  93:    */   {
/*  94: 86 */     if (paramJpsModuleType == null) {
/*  95: 86 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "asTyped" }));
/*  96:    */     }
/*  97: 86 */     return this.d.equals(paramJpsModuleType) ? this : null;
/*  98:    */   }
/*  99:    */   
/* 100:    */   @NotNull
/* 101:    */   public JpsUrlList getContentRootsList()
/* 102:    */   {
/* 103: 92 */     JpsUrlList tmp13_10 = ((JpsUrlList)this.myContainer.getChild(a));
/* 104: 92 */     if (tmp13_10 == null) {
/* 105: 92 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getContentRootsList" }));
/* 106:    */     }
/* 107: 92 */     return tmp13_10;
/* 108:    */   }
/* 109:    */   
/* 110:    */   @NotNull
/* 111:    */   public JpsUrlList getExcludeRootsList()
/* 112:    */   {
/* 113: 97 */     JpsUrlList tmp13_10 = ((JpsUrlList)this.myContainer.getChild(b));
/* 114: 97 */     if (tmp13_10 == null) {
/* 115: 97 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getExcludeRootsList" }));
/* 116:    */     }
/* 117: 97 */     return tmp13_10;
/* 118:    */   }
/* 119:    */   
/* 120:    */   @NotNull
/* 121:    */   public List<JpsModuleSourceRoot> getSourceRoots()
/* 122:    */   {
/* 123:103 */     List tmp18_13 = ((JpsElementCollection)this.myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE)).getElements();
/* 124:103 */     if (tmp18_13 == null) {
/* 125:103 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSourceRoots" }));
/* 126:    */     }
/* 127:103 */     return tmp18_13;
/* 128:    */   }
/* 129:    */   
/* 130:    */   @NotNull
/* 131:    */   public <P extends JpsElement> Iterable<JpsTypedModuleSourceRoot<P>> getSourceRoots(@NotNull JpsModuleSourceRootType<P> paramJpsModuleSourceRootType)
/* 132:    */   {
/* 133:109 */     if (paramJpsModuleSourceRootType == null) {
/* 134:109 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSourceRoots" }));
/* 135:    */     }
/* 136:109 */     Iterable tmp59_54 = ((JpsElementCollection)this.myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE)).getElementsOfType(paramJpsModuleSourceRootType);
/* 137:109 */     if (tmp59_54 == null) {
/* 138:109 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSourceRoots" }));
/* 139:    */     }
/* 140:109 */     return tmp59_54;
/* 141:    */   }
/* 142:    */   
/* 143:    */   @NotNull
/* 144:    */   public <P extends JpsElement> JpsModuleSourceRoot addSourceRoot(@NotNull String paramString, @NotNull JpsModuleSourceRootType<P> paramJpsModuleSourceRootType)
/* 145:    */   {
/* 146:115 */     if (paramString == null) {
/* 147:115 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 148:    */     }
/* 149:115 */     if (paramJpsModuleSourceRootType == null) {
/* 150:115 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 151:    */     }
/* 152:115 */     JpsModuleSourceRoot tmp95_92 = addSourceRoot(paramString, paramJpsModuleSourceRootType, (JpsElement)paramJpsModuleSourceRootType.createDefaultProperties());
/* 153:115 */     if (tmp95_92 == null) {
/* 154:115 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 155:    */     }
/* 156:115 */     return tmp95_92;
/* 157:    */   }
/* 158:    */   
/* 159:    */   @NotNull
/* 160:    */   public <P extends JpsElement> JpsModuleSourceRoot addSourceRoot(@NotNull String paramString, @NotNull JpsModuleSourceRootType<P> paramJpsModuleSourceRootType, @NotNull P paramP)
/* 161:    */   {
/* 162:122 */     if (paramString == null) {
/* 163:122 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 164:    */     }
/* 165:122 */     if (paramJpsModuleSourceRootType == null) {
/* 166:122 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 167:    */     }
/* 168:122 */     if (paramP == null) {
/* 169:122 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 170:    */     }
/* 171:122 */     JpsModuleSourceRootImpl localJpsModuleSourceRootImpl = new JpsModuleSourceRootImpl(paramString, paramJpsModuleSourceRootType, paramP);
/* 172:123 */     addSourceRoot(localJpsModuleSourceRootImpl); JpsModuleSourceRootImpl 
/* 173:124 */       tmp140_138 = localJpsModuleSourceRootImpl;
/* 174:124 */     if (tmp140_138 == null) {
/* 175:124 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 176:    */     }
/* 177:124 */     return tmp140_138;
/* 178:    */   }
/* 179:    */   
/* 180:    */   public void addSourceRoot(@NotNull JpsModuleSourceRoot paramJpsModuleSourceRoot)
/* 181:    */   {
/* 182:129 */     if (paramJpsModuleSourceRoot == null) {
/* 183:129 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addSourceRoot" }));
/* 184:    */     }
/* 185:129 */     ((JpsElementCollection)this.myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE)).addChild(paramJpsModuleSourceRoot);
/* 186:    */   }
/* 187:    */   
/* 188:    */   public void removeSourceRoot(@NotNull String paramString, @NotNull JpsModuleSourceRootType paramJpsModuleSourceRootType)
/* 189:    */   {
/* 190:134 */     if (paramString == null) {
/* 191:134 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "removeSourceRoot" }));
/* 192:    */     }
/* 193:134 */     if (paramJpsModuleSourceRootType == null) {
/* 194:134 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "removeSourceRoot" }));
/* 195:    */     }
/* 196:134 */     JpsElementCollection localJpsElementCollection = (JpsElementCollection)this.myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE);
/* 197:135 */     for (JpsModuleSourceRoot localJpsModuleSourceRoot : localJpsElementCollection.getElements()) {
/* 198:136 */       if ((localJpsModuleSourceRoot.getRootType().equals(paramJpsModuleSourceRootType)) && (localJpsModuleSourceRoot.getUrl().equals(paramString)))
/* 199:    */       {
/* 200:137 */         localJpsElementCollection.removeChild(localJpsModuleSourceRoot);
/* 201:138 */         break;
/* 202:    */       }
/* 203:    */     }
/* 204:    */   }
/* 205:    */   
/* 206:    */   @NotNull
/* 207:    */   public JpsDependenciesList getDependenciesList()
/* 208:    */   {
/* 209:146 */     JpsDependenciesList tmp13_10 = ((JpsDependenciesList)this.myContainer.getChild(c));
/* 210:146 */     if (tmp13_10 == null) {
/* 211:146 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getDependenciesList" }));
/* 212:    */     }
/* 213:146 */     return tmp13_10;
/* 214:    */   }
/* 215:    */   
/* 216:    */   @NotNull
/* 217:    */   public JpsSdkReferencesTable getSdkReferencesTable()
/* 218:    */   {
/* 219:152 */     JpsSdkReferencesTable tmp13_10 = ((JpsSdkReferencesTable)this.myContainer.getChild(JpsSdkReferencesTableImpl.ROLE));
/* 220:152 */     if (tmp13_10 == null) {
/* 221:152 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSdkReferencesTable" }));
/* 222:    */     }
/* 223:152 */     return tmp13_10;
/* 224:    */   }
/* 225:    */   
/* 226:    */   public <P extends JpsElement> JpsSdkReference<P> getSdkReference(@NotNull JpsSdkType<P> paramJpsSdkType)
/* 227:    */   {
/* 228:157 */     if (paramJpsSdkType == null) {
/* 229:157 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSdkReference" }));
/* 230:    */     }
/* 231:157 */     JpsSdkReference localJpsSdkReference = getSdkReferencesTable().getSdkReference(paramJpsSdkType);
/* 232:158 */     if (localJpsSdkReference != null) {
/* 233:159 */       return localJpsSdkReference;
/* 234:    */     }
/* 235:161 */     JpsProject localJpsProject = getProject();
/* 236:162 */     if (localJpsProject != null) {
/* 237:163 */       return localJpsProject.getSdkReferencesTable().getSdkReference(paramJpsSdkType);
/* 238:    */     }
/* 239:165 */     return null;
/* 240:    */   }
/* 241:    */   
/* 242:    */   public <P extends JpsElement> JpsSdk<P> getSdk(@NotNull JpsSdkType<P> paramJpsSdkType)
/* 243:    */   {
/* 244:170 */     if (paramJpsSdkType == null) {
/* 245:170 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getSdk" }));
/* 246:    */     }
/* 247:170 */     JpsSdkReference localJpsSdkReference = getSdkReference(paramJpsSdkType);
/* 248:171 */     if (localJpsSdkReference == null) {
/* 249:171 */       return null;
/* 250:    */     }
/* 251:172 */     JpsTypedLibrary localJpsTypedLibrary = (JpsTypedLibrary)localJpsSdkReference.resolve();
/* 252:173 */     return localJpsTypedLibrary != null ? (JpsSdk)localJpsTypedLibrary.getProperties() : null;
/* 253:    */   }
/* 254:    */   
/* 255:    */   public void delete()
/* 256:    */   {
/* 257:179 */     ((JpsElementCollection)this.myParent).removeChild(this);
/* 258:    */   }
/* 259:    */   
/* 260:    */   @NotNull
/* 261:    */   public JpsModuleReference createReference()
/* 262:    */   {
/* 263:185 */     void tmp11_8 = new JpsModuleReferenceImpl(getName());
/* 264:185 */     if (tmp11_8 == null) {
/* 265:185 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "createReference" }));
/* 266:    */     }
/* 267:185 */     return tmp11_8;
/* 268:    */   }
/* 269:    */   
/* 270:    */   @NotNull
/* 271:    */   public <P extends JpsElement, Type extends JpsLibraryType<P>,  extends JpsElementTypeWithDefaultProperties<P>> JpsLibrary addModuleLibrary(@NotNull String paramString, @NotNull Type paramType)
/* 272:    */   {
/* 273:192 */     if (paramString == null) {
/* 274:192 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addModuleLibrary" }));
/* 275:    */     }
/* 276:192 */     if (paramType == null) {
/* 277:192 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addModuleLibrary" }));
/* 278:    */     }
/* 279:192 */     JpsLibrary tmp93_88 = this.e.addLibrary(paramString, paramType);
/* 280:192 */     if (tmp93_88 == null) {
/* 281:192 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addModuleLibrary" }));
/* 282:    */     }
/* 283:192 */     return tmp93_88;
/* 284:    */   }
/* 285:    */   
/* 286:    */   public void addModuleLibrary(@NotNull JpsLibrary paramJpsLibrary)
/* 287:    */   {
/* 288:197 */     if (paramJpsLibrary == null) {
/* 289:197 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "addModuleLibrary" }));
/* 290:    */     }
/* 291:197 */     this.e.addLibrary(paramJpsLibrary);
/* 292:    */   }
/* 293:    */   
/* 294:    */   @NotNull
/* 295:    */   public JpsLibraryCollection getLibraryCollection()
/* 296:    */   {
/* 297:203 */     JpsLibraryCollection tmp4_1 = this.e;
/* 298:203 */     if (tmp4_1 == null) {
/* 299:203 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getLibraryCollection" }));
/* 300:    */     }
/* 301:203 */     return tmp4_1;
/* 302:    */   }
/* 303:    */   
/* 304:    */   @Nullable
/* 305:    */   public JpsProject getProject()
/* 306:    */   {
/* 307:208 */     JpsModel localJpsModel = getModel();
/* 308:209 */     return localJpsModel != null ? localJpsModel.getProject() : null;
/* 309:    */   }
/* 310:    */   
/* 311:    */   @NotNull
/* 312:    */   public JpsModuleType<P> getModuleType()
/* 313:    */   {
/* 314:215 */     JpsModuleType tmp4_1 = this.d;
/* 315:215 */     if (tmp4_1 == null) {
/* 316:215 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsModuleImpl", "getModuleType" }));
/* 317:    */     }
/* 318:215 */     return tmp4_1;
/* 319:    */   }
/* 320:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.module.impl.JpsModuleImpl

 * JD-Core Version:    0.7.0.1

 */